package org.chen.common.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class IdGenerator {
    private static final String BATCH_PREFIX = "B";
    private static final String DATE_FORMAT = "yyyyMMddHHmmss";
    
    /**
     * 生成批次ID
     * 格式：B + 年月日时分秒 + 3位随机数
     */
    public static String generateBatchId() {
        String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DATE_FORMAT));
        String random = String.format("%03d", new Random().nextInt(1000));
        return BATCH_PREFIX + timestamp + random;
    }
    
    /**
     * 生成回调ID
     * 格式：C + 时间戳 + 3位随机数
     */
    public static String generateCallbackId() {
        return "C" + System.currentTimeMillis() + String.format("%03d", new Random().nextInt(1000));
    }
}